{template 'public/header'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_tcwq/template/public/ygcss.css">
<style type="text/css">
    input[type="radio"] + label::before {
        content: "\a0"; /*不换行空格*/
        display: inline-block;
        vertical-align: middle;
        font-size: 16px;
        width: 1em;
        height: 1em;
        margin-right: .4em;
        border-radius: 50%;
        border: 2px solid #ddd;
        text-indent: .15em;
        line-height: 1; 
    }
    input[type="radio"]:checked + label::before {
        background-color: #44ABF7;
        background-clip: content-box;
        padding: .1em;
        border: 2px solid #44ABF7;
    }
    input[type="radio"] {
        position: absolute;
        clip: rect(0, 0, 0, 0);
    }
</style>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>    
    <li><a href="{php echo $this->createWebUrl('acthx',array('act_id' => $_GPC['act_id']))}">核销员管理</a></li>
    <li class="active"><a href="{php echo $this->createWebUrl('addacthx',array('act_id' => $_GPC['act_id']))}">添加核销员</a></li>
</ul>
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default ygdefault">
            <div class="panel-heading wyheader">
                内容编辑
            </div>
            <div class="panel-body">
                      <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="margin-right: 15px;">绑定微信端核销员</label>
                    <select class="col-sm-4" id="username" name="user_id">
                     <option value="0">请选择管理员</option>
                        {loop $user $key $item}
                        {if $item['id']==$info['user_id']}
                        <option value="{$item['id']}" selected="selected" name="unopction">{$item['name']}</option>
                        {else}
                        <option value="{$item['id']}" name="unopction">{$item['name']}</option>
                        {/if}
                        {/loop}
                    </select>
                    <span class="btn btn-sm storeblue" data-toggle="modal" data-target="#myModal1" style="margin-left: 30px;">搜索核销员</span>
                    <div class="col-xs-12 col-sm-9 col-md-10 col-sm-push-3 col-md-push-2 ">
                    </div>
                    <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                  <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                                </div>
                                <div class="modal-body ygsearch" style="font-size: 20px;padding: 15px 30px;">
                                    <input type="text" id="ygsinput" placeholder="请输入昵称/openid">
                                    <span class="btn btn-sm ygbtn storeblue">搜索</span>
                                    <div class="searchname" style="margin-top: 8px;"></div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                </div>
                            </div>
                        </div>
                    </div>   
              </div>
<input type="hidden" id="act_id" value="{$_GPC['act_id']}">
            </div>
        </div>
        <div class="form-group">
            <input type="submit" name="submit" value="提交" class="btn col-lg-3" style="color: white;background-color: #44ABF7;"/>
            <input type="hidden" name="token" value="{$_W['token']}" />
            <input type="hidden" name="id" value="{$info['id']}" />
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-20").show();
        $("#yframe-20").addClass("wyactive");


              // —————————————管理员搜索事件———————————————
        $(".searchname").hide();
        $(".ygbtn").on("click",function(){
            var ygsinput = $("#ygsinput").val();
            var act_id = $("#act_id").val();
            console.log(ygsinput)
            if(ygsinput.length==''){
              $(".searchname").html('');
            }else{
              $(".searchname").html('')  
              var keywords = $("#ygsinput").val()
              $.ajax({
                  type:"post",
                  url:"{$_W['siteroot']}/app/index.php?i={$_W['uniacid']}&c=entry&do=FindUser2&m=zh_tcwq",
                  dataType:"text",
                  data:{keywords:keywords,act_id:act_id},
                  success:function(data){                    
                      var data = eval('(' + data + ')')
                      console.log(data);
                      $(".searchname").show();
                      for(var i=0;i<data.length;i++){
                        $(".searchname").append('<div class="shnbox" data-dismiss="modal" id="'+data[i].id+'"><a href="javascript:void(0);"><p>'+data[i].name+'</p></a></div>')
                      }
                      $(".shnbox").each(function(){
                        $(this).click(function(){
                            // console.log($(this).attr("id"));
                            // $("#username").val($(this).html())
                            var thid = $(this).attr("id");
                            $('#username option[value='+thid+']').attr("selected", true);
                        })
                        
                      })
                      
                  }
              }) 
            }
            
        })
    })
</script>{template 'common/footer'}